import Request from '../utils/request'
import { Dict } from './types/dict'
import { Wrapper } from './types/result'
import { ApprovalQuery, CCPlatform, CCPlatformQuery, ModelQuery, TargetPlatform, TargetPlatformByIdQuery, TargetPlatformId, TargetUser, TaskQuery } from './types/task'

/**
 * 指令任务字典
 */
export function dictinfo (key: string) {
  return Request<Wrapper<Array<Dict>>>({
    url: `/api/dictinfo/${key}`,
    method: 'GET',
  })
}
/**
 * 任务发送-指令任务
 */

export function sendTask(query: TaskQuery) {
  return Request<Wrapper<boolean>>({
    url: '/api/app/taskinfo',
    method: 'POST',
    data: query
  })
}

/**
 * 获取目标平台id
 */
export function getTargetPlatformId() {
  return Request({
    url: '/api/org/allOrg',
    method: 'GET'
  })
}

/**
 * 通过目标平台id获取具体目标平台
 */
export function getTargetPlatformById(query: TargetPlatformByIdQuery) {
  return Request<Wrapper<Array<TargetPlatform>>>({
    url: '/api/org/taskDistribution',
    method: 'GET',
    params: query
  })
}

/**
 * 获取模板id
 */
 export function getModelId(query: any) {
  return Request<Wrapper<string>>({
    url: '/api/templateinfo',
    method: 'POST',
    data: query
  })
}

/**
 * 获取审批人
 */
export function getApprovalUser(query: ApprovalQuery) {
  return Request<Wrapper<Array<TargetUser>>>({
    url: '/api/app/taskinfo/getApproval',
    method: 'GET',
    params: query
  })
}

/**
 * 获取抄送机构
 */
 export function getCCPlatform(params:CCPlatformQuery) {
  return Request<Wrapper<Array<CCPlatform>>>({
    url: '/api/org/ccEcho',
    method: 'POST',
    data:params
  })
}

/**
 * 获取抄送人
 */
export function getTargetUser() {
  return Request<Wrapper<Array<TargetUser>>>({
    url: '/api/org/findCCUser',
    method: 'GET'
  })
}